package org.javaboy.msg;

import org.javaboy.msg.queue.DelayMsgQueue;
import org.javaboy.msg.redis.RedisClient;

import java.util.Date;
import java.util.Scanner;

public class Demo {
    public static void main(String[] args) {
        new RedisClient().execute(jedis -> {
            // 创建延迟消息队列
            DelayMsgQueue delayMsgQueue = new DelayMsgQueue(jedis, "javaboy_delay_msg_queue");
            new Thread(() -> {
                for (int i = 0; i < 10; i++) {
                    delayMsgQueue.send(new Date() + "hello" + i, 10);
                }
            }).start();
            new Thread(() -> {
                delayMsgQueue.receive();
            }).start();
        });
        new Scanner(System.in).next();
    }
}
